home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / BBS / EZY120_1.ZIP / STRUCT.ARJ / CLIB.ARJ / STR7.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-09  |  510 b   |  23 lines

  1.  
  2. #include <string.h>
  3.  
  4. char *ReplaceStr(char *StrSource,char *StrToFind,char *StrToReplace)
  5. {
  6.   char *Temp = new char[strlen(StrSource)+1];
  7.   strcpy(Temp,StrSource);
  8.   strupr(Temp);
  9.   char *Ptr, *OPtr;
  10.   OPtr = Ptr = Temp;
  11.   *StrSource = '\0';
  12.   while ((Ptr = strstr(Ptr,StrToFind)) != NULL) {
  13.     *Ptr = '\0';
  14.     strcat(StrSource,OPtr);
  15.     strcat(StrSource,StrToReplace);
  16.     Ptr += strlen(StrToFind);
  17.     OPtr = Ptr;
  18.   }
  19.   strcat(StrSource,OPtr);
  20.   delete Temp;
  21.   return(StrSource);
  22. }
  23.